const { Router } = require('express');
const bodyParser = require('body-parser');
const TodoController = require('../controllers/Todo');

const router = new Router();
const jsonParser = bodyParser.json();

const { listView, detailView, addTodo, toggleTodo, removeTodo } =
  new TodoController();

router.get('/', listView);
router.get('/detail/:id', detailView);
router.post('/add_todo', jsonParser, addTodo);
router.post('/toggle_todo', jsonParser, toggleTodo);
router.post('/remove_todo', jsonParser, removeTodo);

module.exports = router;
